home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 7: Sunsite / Linux Cubed Series 7 - Sunsite Vol 1.iso / system / network / file-tra / rdist-6.1 / rdist-6 / rdist-6.1.0-linuxpl2 / README.Linux < prev    next >
Encoding:
Text File  |  1995-10-21  |  7.8 KB  |  268 lines

  1. This is a version of rdist for Linux which fixes two things against
  2. the orignal 6.1.0 version:
  3.  
  4. - partial read and write problem, which caused rdidst to hang for Linux,
  5.   fixed by Mark Eichin, eichin@cygnus.com
  6.  
  7. - Changes to make rdist work with the secure remote shell, ssh, by
  8.   Tatu Ylonen, available from ftp://ftp.cs.hut.fi/pub/ssh.
  9.  
  10. To see what I've changed against the original sources, the patch follows.
  11. If you want to reverse it, do a "patch -p1 < REAME.Linux" in the rdist
  12. source directory.
  13.  
  14. diff -u --recursive rdist-6.1.0/include/defs.h rdist-6.1.0-linuxpl2/include/defs.h
  15. --- rdist-6.1.0/include/defs.h    Tue Apr 12 01:19:22 1994
  16. +++ rdist-6.1.0-linuxpl2/include/defs.h    Mon Oct 16 19:43:18 1995
  17. @@ -325,7 +325,8 @@
  18.  extern opt_t         options;    /* Global options */
  19.  extern int         proto_version;    /* Protocol version number */
  20.  extern int         realargc;    /* Real argc */
  21. -extern int         rem;        /* Remote file descriptor */
  22. +extern int        rem_r;        /* Remote file descriptor, reading */
  23. +extern int         rem_w;        /* Remote file descriptor, writing */
  24.  extern int         rtimeout;    /* Response time out in seconds */
  25.  extern UID_T         userid;        /* User ID of rdist user */
  26.  extern jmp_buf         finish_jmpbuf;    /* Setjmp buffer for finish() */
  27. diff -u --recursive rdist-6.1.0/mf/Makefile.var rdist-6.1.0-linuxpl2/mf/Makefile.var
  28. --- rdist-6.1.0/mf/Makefile.var    Tue Apr 12 01:20:17 1994
  29. +++ rdist-6.1.0-linuxpl2/mf/Makefile.var    Mon Jun  5 16:57:30 1995
  30. @@ -95,7 +95,7 @@
  31.  #
  32.  #YACC         = bison -y
  33.  
  34. -OPT        = -g
  35. +OPT        = -O2 -fomit-frame-pointer
  36.  RM        = rm
  37.  AR        = ar
  38.  RANLIB        = ranlib
  39. diff -u --recursive rdist-6.1.0/src/child.c rdist-6.1.0-linuxpl2/src/child.c
  40. --- rdist-6.1.0/src/child.c    Thu Mar 31 04:56:26 1994
  41. +++ rdist-6.1.0-linuxpl2/src/child.c    Mon Jun  5 16:49:38 1995
  42. @@ -203,8 +203,16 @@
  43.          debugmsg(DM_MISC, "[readchild(%s, %d, %d) got %d bytes]", 
  44.               child->c_name, child->c_pid, child->c_readfd, amt);
  45.  
  46. -        write(fileno(stdout), rbuf, amt);
  47. -
  48. +        {
  49. +            int wamt=amt, ramt, woff=0;
  50. +            while ((ramt = write(fileno(stdout), rbuf+woff, wamt)) > 0) {
  51. +                woff += ramt; wamt -= ramt;
  52. +                debugmsg(DM_MISC,
  53. +                     "[readchild(%s, %d, %d) only wrote %d/%d bytes]",
  54. +                     child->c_name, child->c_pid, child->c_readfd, 
  55. +                     ramt, wamt);
  56. +            }
  57. +        }
  58.          debugmsg(DM_MISC, "[readchild(%s, %d, %d) write done]",
  59.               child->c_name, child->c_pid, child->c_readfd);
  60.      }
  61. diff -u --recursive rdist-6.1.0/src/client.c rdist-6.1.0-linuxpl2/src/client.c
  62. --- rdist-6.1.0/src/client.c    Fri Apr 22 19:24:01 1994
  63. +++ rdist-6.1.0-linuxpl2/src/client.c    Mon Oct 16 19:44:27 1995
  64. @@ -429,12 +429,18 @@
  65.               * this situation gracefully.
  66.               */
  67.          }
  68. -        if (write(rem, buf, amt) == -1) {
  69. -            error("%s: Error writing to client: %s", 
  70. -                  target, SYSERR);
  71. -            err();
  72. -            ++goterr;
  73. -            break;
  74. +        {
  75. +            int ramt, wamt=amt, woff=0;
  76. +            while((ramt=write(rem_w,buf+woff,wamt)) > 0) {
  77. +                woff += ramt; wamt -= ramt;
  78. +            }
  79. +            if (ramt < 0) {
  80. +                error("%s: Error writing to client: %s", 
  81. +                      target, SYSERR);
  82. +                err();
  83. +                ++goterr;
  84. +                break;
  85. +            }
  86.          }
  87.          (void) alarm(0);
  88.      }
  89. diff -u --recursive rdist-6.1.0/src/common.c rdist-6.1.0-linuxpl2/src/common.c
  90. --- rdist-6.1.0/src/common.c    Wed Apr 20 20:11:03 1994
  91. +++ rdist-6.1.0-linuxpl2/src/common.c    Mon Oct 16 19:53:09 1995
  92. @@ -64,7 +64,8 @@
  93.  int            do_fork = 1;        /* Fork child process */
  94.  char               *currenthost = NULL;    /* Current client hostname */
  95.  char               *progname = NULL;    /* Name of this program */
  96. -int            rem = -1;        /* Client file descriptor */
  97. +int            rem_r = -1;        /* Client file descriptor */
  98. +int            rem_w = -1;        /* Client file descriptor */
  99.  struct passwd           *pw = NULL;        /* Local user's pwd entry */
  100.  int             contimedout = FALSE;    /* Connection timed out */
  101.  int            proto_version = -1;    /* Protocol version */
  102. @@ -176,7 +177,7 @@
  103.      /* Prevent looping */
  104.      (void) signal(SIGPIPE, SIG_IGN);
  105.  
  106. -    rem = -1;        /* Ensure we don't try to send to server */
  107. +    rem_r = rem_w = -1;    /* Ensure we don't try to send to server */
  108.      checkhostname();
  109.      error("Lost connection to %s", 
  110.            (currenthost) ? currenthost : "(unknown)");
  111. @@ -247,7 +248,7 @@
  112.  {
  113.      int len;
  114.  
  115. -    if (rem < 0)
  116. +    if (rem_w < 0)
  117.          return(-1);
  118.  
  119.      /*
  120. @@ -268,7 +269,13 @@
  121.           (cmd == C_NONE) ? len-1 : len-2,
  122.           (cmd == C_NONE) ? msg : msg + 1);
  123.  
  124. -    return(!(write(rem, msg, len) == len));
  125. +    {
  126. +        int ramt, wamt=len, woff=0;
  127. +        while((ramt = write(rem_w,msg+woff,wamt)) > 0) {
  128. +            woff += ramt; wamt -= ramt;
  129. +        }
  130. +        return ramt<0;
  131. +    }
  132.  }
  133.  
  134.  /*
  135. @@ -368,7 +375,7 @@
  136.      (void) signal(SIGALRM, sighandler);
  137.      (void) alarm(rtimeout);
  138.  
  139. -    remleft = remread(rem, rembuf, sizeof(rembuf));
  140. +    remleft = remread(rem_r, rembuf, sizeof(rembuf));
  141.  
  142.      (void) alarm(0);
  143.  
  144. @@ -396,7 +403,7 @@
  145.      register int c, left = space;
  146.      register u_char *p = buffer;
  147.  
  148. -    if (rem < 0) {
  149. +    if (rem_r < 0) {
  150.          error("Cannot read remote input: Remote descriptor not open.");
  151.          return(-1);
  152.      }
  153. @@ -460,7 +467,7 @@
  154.          (void) signal(SIGALRM, sighandler);
  155.          (void) alarm(rtimeout);
  156.  
  157. -        remleft = remread(rem, rembuf, sizeof(rembuf));
  158. +        remleft = remread(rem_r, rembuf, sizeof(rembuf));
  159.  
  160.          (void) alarm(0);
  161.          remptr = rembuf;
  162. @@ -808,7 +815,7 @@
  163.                  continue;
  164.              }
  165.              if (isserver)
  166. -                (void) write(rem, sbuf, s - sbuf);
  167. +                (void) write(rem_w, sbuf, s - sbuf);
  168.              else {
  169.                  *s = CNULL;
  170.                  message(MT_INFO, "%s", sbuf+1);
  171. @@ -819,7 +826,7 @@
  172.      if (s > (char *) &sbuf[1]) {
  173.          *s++ = '\n';
  174.          if (isserver)
  175. -            (void) write(rem, sbuf, s - sbuf);
  176. +            (void) write(rem_w, sbuf, s - sbuf);
  177.          else {
  178.              *s = CNULL;
  179.              message(MT_INFO, "%s", sbuf+1);
  180. @@ -885,7 +892,7 @@
  181.  }
  182.  
  183.  extern char *basename(path)
  184. -    char *path;
  185. +    const char *path;
  186.  {
  187.      register char *cp;
  188.   
  189. diff -u --recursive rdist-6.1.0/src/docmd.c rdist-6.1.0-linuxpl2/src/docmd.c
  190. --- rdist-6.1.0/src/docmd.c    Tue Apr 26 19:10:09 1994
  191. +++ rdist-6.1.0-linuxpl2/src/docmd.c    Mon Oct 16 19:47:20 1995
  192. @@ -72,13 +72,15 @@
  193.  {
  194.      debugmsg(DM_CALL, "closeconn() called\n");
  195.  
  196. -    if (rem >= 0) {
  197. +    if (rem_w >= 0) {
  198.          /* We don't care if the connection is still good or not */
  199.          signal(SIGPIPE, SIG_IGN);    
  200.  
  201.          (void) sendcmd(C_FERRMSG, NULL);
  202. -        (void) close(rem);
  203. -        rem = -1;
  204. +        (void) close(rem_w);
  205. +        (void) close(rem_r); /* This can't hurt */
  206. +        rem_w = -1;
  207. +        rem_r = -1;
  208.      }
  209.  }
  210.  
  211. @@ -313,7 +315,7 @@
  212.      /*
  213.       * See if we're already connected to this host
  214.       */
  215. -    if (cur_host != NULL && rem >= 0) {
  216. +    if (cur_host != NULL && rem_w >= 0) {
  217.          if (strcmp(cur_host, rhost) == 0)
  218.              return(1);
  219.          closeconn();
  220. @@ -345,7 +347,7 @@
  221.  
  222.      (void) sprintf(buf, "%.*s -S", sizeof(buf)-5, path_rdistd);
  223.          
  224. -    if ((rem = remotecmd(rhost, locuser, ruser, buf)) < 0)
  225. +    if ((rem_r = rem_w = remotecmd(rhost, locuser, ruser, buf)) < 0)
  226.          return(0);
  227.  
  228.      /*
  229. diff -u --recursive rdist-6.1.0/src/message.c rdist-6.1.0-linuxpl2/src/message.c
  230. --- rdist-6.1.0/src/message.c    Wed Apr 20 19:53:29 1994
  231. +++ rdist-6.1.0-linuxpl2/src/message.c    Mon Oct 16 19:48:25 1995
  232. @@ -325,7 +325,7 @@
  233.      char cmd;
  234.  
  235.      if (isserver) {
  236. -        if (rem < 0 || IS_ON(flags, MT_NOREMOTE))
  237. +        if (rem_w < 0 || IS_ON(flags, MT_NOREMOTE))
  238.              return;
  239.  
  240.          cmd = CNULL;
  241. diff -u --recursive rdist-6.1.0/src/rdistd.c rdist-6.1.0-linuxpl2/src/rdistd.c
  242. --- rdist-6.1.0/src/rdistd.c    Sat Feb 26 00:53:38 1994
  243. +++ rdist-6.1.0-linuxpl2/src/rdistd.c    Mon Oct 16 19:53:52 1995
  244. @@ -95,8 +95,9 @@
  245.          exit(1);
  246.      }
  247.  
  248. -    /* Use stdin for remote descriptor */
  249. -    rem = fileno(stdin);
  250. +    /* Use stdin and stdout for remote descriptors */
  251. +    rem_r = fileno(stdin);
  252. +    rem_w = fileno(stdout);
  253.  
  254.      /* Set logging */
  255.      if (cp = msgparseopts(localmsglist, TRUE))
  256. diff -u --recursive rdist-6.1.0/src/server.c rdist-6.1.0-linuxpl2/src/server.c
  257. --- rdist-6.1.0/src/server.c    Tue Apr 26 18:58:56 1994
  258. +++ rdist-6.1.0-linuxpl2/src/server.c    Mon Jun  5 17:03:51 1995
  259. @@ -230,7 +230,7 @@
  260.      } else
  261.          gid = gr->gr_gid;
  262.  
  263. -    if (userid && gid >= 0 && gid != primegid) {
  264. +    if (userid && gid >= 0x7fff && gid != primegid) {
  265.          if (gr)
  266.              for (i = 0; gr->gr_mem[i] != NULL; i++)
  267.                  if (strcmp(locuser, gr->gr_mem[i]) == 0)
  268.